package br.ufpe.cin.imlm2.jbeat.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import br.ufpe.cin.imlm2.util.ArgumentsValidator;

/**
 * @author irineu
 */
public class LightWeightClass implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7357674434162350739L;

	private List<LightWeightMethod> methods;
	private LightWeightReferenceType type;

	public LightWeightClass( List<LightWeightMethod> methods, LightWeightReferenceType type ) {
		super();
		ArgumentsValidator.verifyNullness( methods, type );
		this.methods = methods;
		this.type = type;
	}

	public LightWeightClass( LightWeightReferenceType type ) {
		this( new ArrayList<LightWeightMethod>(), type );
	}

	public void addMethod( LightWeightMethod meth ) {
		this.methods.add( meth );
	}

	public List<LightWeightMethod> getMethods() {
		return methods;
	}

	public List<LightWeightMethod> getMethods( String name ) {
		List<LightWeightMethod> meths = new ArrayList<LightWeightMethod>();
		for ( LightWeightMethod lightWeightMethod : this.methods ) {
			if ( lightWeightMethod.getName().equals( name ) )
				meths.add( lightWeightMethod );
		}
		return meths;
	}

	public LightWeightReferenceType getType() {
		return type;
	}

	public String getFullyQualifiedName() {
		return this.type.getFullyQualifiedName();
	}

	@Override
	public String toString() {
		return this.getFullyQualifiedName();
	}

}
